package leetcode.medium.numofminutes;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * <h4>
 *     <a href="https://leetcode.cn/problems/time-needed-to-inform-all-employees/">
 *         1376. Time Needed to Inform All Employees [Medium]
 *     </a>
 * </h4>
 * <h4>How to solve this question?</h4>
 * <p>
 *     It's a multi-way tree with weight on its nodes. The task is to find a path from the root to one of its leaf
 *     nodes in which the corresponding cumulative path sum is the greatest among all possible paths.<br/>
 *     Use dfs to solve this question.
 * </p>
 */
public class SolutionTest {
    private static Solution solution;

    @BeforeClass
    public static void setup() {
        solution = new Solution();
    }

    @AfterClass
    public static void tearUp() {
        solution = null;
    }

    @Test
    public void test1() {
        int[] managers = new int[] {-1};
        int[] inform = new int[] {0};
        int n = 1, headId = 0;
        Assert.assertEquals(0, solution.numOfMinutes(n, headId, managers, inform));
    }

    @Test
    public void test2() {
        int[] managers = new int[] {2,2,-1,2,2,2};
        int[] inform = new int[] {0,0,1,0,0,0};
        int n = 6, headId = 2;
        Assert.assertEquals(1, solution.numOfMinutes(n, headId, managers, inform));
    }

    @Test
    public void test3() {
        int[] managers = new int[] {-1,0,0,1,2};
        int[] inform = new int[] {1,2,3,0,0};
        int n = 5, headId = 0;
        Assert.assertEquals(4, solution.numOfMinutes(n, headId, managers, inform));
    }
}
